package com.only4play.productcenter.domain.templateitem;

/**
 * @author hinzzz www.hinzzz.cn 157957329@qq.com
 * 2024-02-28
 */
import com.only4play.codegen.processor.api.GenCreateRequest;
import com.only4play.codegen.processor.api.GenFeign;
import com.only4play.codegen.processor.api.GenQueryRequest;
import com.only4play.codegen.processor.api.GenResponse;
import com.only4play.codegen.processor.api.GenUpdateRequest;
import com.only4play.codegen.processor.controller.GenController;
import com.only4play.codegen.processor.creator.GenCreator;
import com.only4play.codegen.processor.mapper.GenMapper;
import com.only4play.codegen.processor.query.GenQuery;
import com.only4play.codegen.processor.repository.GenRepository;
import com.only4play.codegen.processor.service.GenService;
import com.only4play.codegen.processor.creator.IgnoreCreator;
import com.only4play.codegen.processor.updater.IgnoreUpdater;
import com.only4play.codegen.processor.service.GenServiceImpl;
import com.only4play.codegen.processor.updater.GenUpdater;
import com.only4play.codegen.processor.vo.GenVo;
import com.only4play.common.annotation.FieldDesc;
import com.only4play.common.constants.ValidStatus;
import com.only4play.jpa.converter.ValidStatusConverter;
import com.only4play.jpa.support.BaseJpaAggregate;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;

import com.only4play.productcenter.infrastructure.constants.Constants;
import lombok.Data;

@GenVo(pkgName = "com.only4play.productcenter.domain.templateitem.vo")
@GenCreator(pkgName = "com.only4play.productcenter.domain.templateitem.creator")
@GenUpdater(pkgName = "com.only4play.productcenter.domain.templateitem.updater")
@GenRepository(pkgName = "com.only4play.productcenter.domain.templateitem.repository")
@GenService(pkgName = "com.only4play.productcenter.domain.templateitem.service")
@GenServiceImpl(pkgName = "com.only4play.productcenter.domain.templateitem.service")
@GenQuery(pkgName = "com.only4play.productcenter.domain.templateitem.query")
@GenMapper(pkgName = "com.only4play.productcenter.domain.templateitem.mapper")
@GenController(pkgName = "com.only4play.productcenter.controller")
@GenCreateRequest(pkgName = "com.only4play.productcenter.api.templateitem.request",sourcePath = Constants.GEN_API_SOURCE)
@GenUpdateRequest(pkgName = "com.only4play.productcenter.api.templateitem.request",sourcePath = Constants.GEN_API_SOURCE)
@GenQueryRequest(pkgName = "com.only4play.productcenter.api.templateitem.request",sourcePath = Constants.GEN_API_SOURCE)
@GenResponse(pkgName = "com.only4play.productcenter.api.templateitem.response",sourcePath = Constants.GEN_API_SOURCE)
@GenFeign(pkgName = "com.only4play.productcenter.api.templateitem.service",sourcePath = Constants.GEN_API_SOURCE,serverName ="product-srv")
@Entity
@Table(name = "template_item_category")
@Data
public class TemplateItemCategory extends BaseJpaAggregate {

    @FieldDesc(name = "父id")
    private Long pid;
    
    @FieldDesc(name = "名称")
    private String name;
    
    @FieldDesc(name = "排序")
    private Integer sortNum;

  @Convert(converter = ValidStatusConverter.class)
  @IgnoreUpdater
  @IgnoreCreator
  private ValidStatus validStatus;

  public void init() {
    setValidStatus(ValidStatus.VALID);
  }

  public void valid(){
    setValidStatus(ValidStatus.VALID);
  }

  public void invalid(){
    setValidStatus(ValidStatus.INVALID);
  }
}